<!DOCTYPE html>
<html>
<head>
	<title>修改试卷类别</title> <@h.head />
	<style type="text/css">
		body {
			padding-bottom: 40px;
		}

		.sidebar-nav {
			padding: 9px 0;
		}

		@media ( max-width : 980px) {
			/* Enable use of floated navbar text */
			.navbar-text.pull-right {
				float: none;
				padding-left: 5px;
				padding-right: 5px;
			}
		}
	</style>
</head>
<body>
<form action="${path}/class/update-class" id="fm" method="post"
	  class="definewidth m20">
	<div style="text-align: center;" id="errorMsg"></div>
	<input type="hidden" value="${levelId!0}" name="levelId">
	<input type="hidden" value="${classId!0}" name="id">
	<table class="table table-bordered table-hover definewidth m10">
		<tr>
			<td width="10%" class="tableleft">试卷分类名称<span class="required">*</span></td>
			<td><input type="text" id="className" name="name" datatype="*"
					   nullmsg="请输入试卷分类名称！" value="${dto.name}" /> <span class="Validform_checktip">请输入试卷分类名称！</span></td>
		</tr>
		<tr>
			<td class="tableleft">答题方式</td>
			<td>
				<select name="method" class="easyui-combobox">
					<#if dto.method == 1>
						<option value="1" selected>练习</option>
						<option value="2">考试</option>
						<#else>
							<option value="1">练习</option>
							<option value="2" selected>考试</option>
					</#if>
				</select>
			</td>
		</tr>
		<tr>
			<td class="tableleft">排序</td>
			<td><input type="text" name="showOrder" class="easyui-numberbox" value="${dto.showOrder}"/></td>
		</tr>
		<tr>
			<td class="tableleft"></td>
			<td>
				<button type="button" id="doSave" class="btn btn-primary" >保存</button>
				&nbsp;&nbsp;
				<button type="button" class="btn btn-success" onclick="goModifyLevel()">返回列表</button>
			</td>
		</tr>
	</table>
</form>
<@h.foot />
<script type="text/javascript">
    $('#doSave').click(function() {
        var className= $("#levelName").val();
        if(className==''){
            alert('试卷分类名称!');
            return;
        }

        var url = "${path}/class/update-class";
        $.ajax({
            cache: true,
            type: "POST",
            url: url,
            data:$('#fm').serialize(),// 你的formid
            async: false,
            error: function(request) {
                alert("请求出问题.");
            },
            success: function(data) {
                var myData = JSON.parse(data);
                if (myData.status == 0) {
                    window.location.href = "${path}/level/modify?id=${levelId!0}";
                } else {
                    alert(myData.msg);
                }
            }
        });

    });
    function goModifyLevel() {
        window.location.href = "${path}/level/modify?id=${levelId!0}";
	}
    var callback = function(data) {
        if (data.status == "0") {
            window.location.href = "${path}/level/modify?id=${levelId!0}";
        } else {
            $("#errorMsg").html(data.msg).show();
        }
    }
    $("#fm").validFrom(callback);
</script>
</body>
</html>